<template>
	<view class="container">
		<!-- 评价 -->
		<view v-for="(item,index) in evaluationList" :key="index">
			<view class="eva-section">
				<view class="eva-box">
					<image class="portrait" :src="item.userHead" mode="aspectFill"></image>
					<view class="right">
						<text class="name">{{item.isAnonymous==1?'匿名':item.mName}}</text>
						<text class="con">{{item.createTime}}</text>
					</view>
					<uni-rate max="5" :value="item.description" disabled="true" color="#eee" active-color="#ee3434"></uni-rate>
				</view>
			</view>
			<view class="eva-box-content">
				<text>{{item.descContent||""}}</text>
				<view>
					<image :src="item_img" v-for="(item_img,i) in item.imgs" :key="i"></image>
				</view>
			</view>
			<view v-if="item.reply" class="reply" :class="{active:index==(evaluationList.length-1)}">{{item.reply}}</view>
		</view>
		<uni-load-more :status="status"></uni-load-more>
	</view>
</template>

<script>
	import uniRate from "@/pages/aduit/components/uni-rate/uni-rate.vue"
	import uniLoadMore from '@/pages/aduit/components/uni-load-more/uni-load-more.vue';
	import ajax from '@/common/request.js';
	import api from '@/common/api.js';
	var that = "";
	export default {
		components: {
			uniLoadMore,
			uniRate
		},
		data() {
			return {
				status: "loading",
				shopId: "",
				evaluationList: [],
				pageNo: 1,
				pageAll: 2
			}
		},
		onLoad(e) {
			that = this;
			that.proid = e.proid
		},
		onShow() {
			that.loadData()
		},
		//上拉加载
		onReachBottom() {
			that.loadData()
		},
		methods: {
			loadData() {
				if (that.pageNo <= that.pageAll) {
					ajax({
						url: "/shopProduct/getAllianceOrderEvaluation",
						method: "GET",
						data: {
							productId: that.proid,
							PageNo: that.pageNo
						},
						success(d) {
							that.pageNo=that.pageNo*1+1;
							that.pageAll=d.totalPage;
							if(that.pageNo>that.pageAll){
							
								that.status="noMore"
							}
							d.lists.forEach((item)=>{
								item.mName=item.mName?item.mName.substr(0,2)+"***":"匿名";
								item.createTime=api.format(item.createTime);
							})
							that.evaluationList=that.evaluationList.concat(d.lists);
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	/* 评价 */
	.eva-section {
		display: flex;
		flex-direction: column;
		padding: 20rpx 30rpx;
		background: #fff;
		margin-top: 16rpx;
		padding-bottom: 0;

		.e-header {
			display: flex;
			align-items: center;
			height: 70rpx;
			font-size: $font-sm + 2rpx;
			color: $font-color-light;

			.tit {
				font-size: $font-base + 2rpx;
				color: $font-color-light;
				margin-right: 4rpx;
			}

			.tip {
				flex: 1;
				text-align: right;
			}

			.icon-you {
				margin-left: 10rpx;
			}
		}
	}

	.eva-box {
		display: flex;
		padding: 20rpx 0;

		.portrait {
			flex-shrink: 0;
			width: 80rpx;
			height: 80rpx;
			border-radius: 100px;
		}

		.right {
			flex: 1;
			display: flex;
			flex-direction: column;
			font-size: $font-base;
			color: $font-color-base;
			padding-left: 26rpx;

			.con {
				font-size: $font-base;
				color: $font-color-light;
			}
		}
	}

	.eva-box-content {
		background: #fff;
		padding: 0 30rpx 30rpx;
		font-size: 28rpx;

		image {
			width: 200rpx;
			height: 200rpx;
			margin-right: 30rpx;
		}
	}
	.reply{
		font-size: 26rpx;
		border-top: 1px solid #eee;
		border-bottom:1px solid #eee;
		padding:30rpx;
		&.active{
			border-bottom: none;
		}
	}
</style>
